#!/usr/local/bin/python
import json
import utils
import sys

input_file = open(sys.argv[1], 'r');
output_file = open(sys.argv[2], 'w');

di = {};

def prettyPrint(queryID, queryString, AppID, AppString, AppDes):
    print '%s : %s' %(queryID, queryString);
    print '------------------------------------------'
    print '%s : %s' %(AppID, AppString);
    print AppDes;
    
for line in input_file:
    li = line.strip('\n').split('\t');
    queryID = li[0];
    queryString = li[1];
    AppID = li[2];
    AppString = li[4];
    AppDes = li[5];
    prettyPrint(queryID, queryString, AppID, AppString, AppDes);
    score = int(raw_input('please input your score:'));
    while score > 3 or score < -1:
        prettyPrint(queryID, queryString, AppID, AppString, AppDes);
        score = int(raw_input('please input your score:'));
    if score < 0:
        continue;  
    if di.has_key(queryString):
        di[queryString][AppID] = score;
    else:
        di[queryString] = {};
        di[queryString][AppID] = score;


json.dump(di, output_file);
input_file.close();
output_file.close();
